<?php
/**
 * Created by PhpStorm.
 * User: 96151
 * Date: 2019/3/25
 * Time: 11:15
 */
namespace app\common\redis;

use app\common\model\activity\ActivityProfitModel;

/**
 * 活动奖励发放情况
 * Class ActivityReward
 */
class ActivityRewardCountRedis
{
    /**
     * Redis配置名称
     * @var string
     */
    public $redis = 'default';

    // 活动奖励总计
    public $user_activity_reward_count_redis_key = "str:user_activity_reward_count_";

    // 获取奖励人数
    public $activity_reward_user_id_list_redis_key = "set:activity_reward_user_id_list_";

    
    /**
     * 获取一个用户的一个类型的奖励条数
     * @param int 		$activity_id 活动编号
     * @param int 		$user_id	  用户编号
     * @param string 	$type		  类型
     * @return int
     */
    public function get_user_profit_count( $activity_id, $user_id ,$type )
    {
        $ActivityProfitModel = ActivityProfitModel::getInstance();

        $where = [
            "type" => $type,
            "user_id" => $user_id,
            "activity_id" => $activity_id
        ];

        return (int) $ActivityProfitModel->where( $where )->count();
    }



}